home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Gui4Cli / Dir / Dir.search < prev    next >
Encoding:
Text File  |  1980-01-03  |  3.7 KB  |  196 lines

  1. G4C
  2.  
  3. ; dir.search gui
  4.  
  5. ; this gui will take the files you have chosen in dir.gc and load them
  6. ; into a file list. You can then search this file list for any string.
  7. ; the results will be displayed in an other lv.
  8.  
  9.  
  10. WinBig -1 -1 400 145 'Getting Files'
  11. WinType 11110001
  12. varpath 'dir.gc'
  13.  
  14. Box 0 0 0 0 out button
  15.  
  16.  
  17. xOnLoad
  18. sc_ci  = ''
  19. sc.mode = FIL
  20. sc_flg = ''
  21. if $$lv.id > ''
  22.    sc_id = $$lv.id
  23. else
  24.    sc_id = 1
  25. endif
  26. sc_dir = $$LV.DIR
  27. gosub dir.search startup   
  28. run 'resident guis:c/fsearch pure add'
  29.  
  30. xOnReload            ; cause if lvmulti finds an error it will stop
  31. if $$lv.id > ''
  32.    sc_id = $$lv.id
  33. else
  34.    sc_id = 1
  35. endif
  36. sc_dir = $$LV.DIR
  37. gosub dir.search startup    ; and gui will remain loaded
  38.  
  39. xroutine startup
  40. setscreen dir.search $*SCREEN
  41. setscreen dir.Gauge $*SCREEN
  42. setgad dir.search 4 hide
  43. sc.filecount = 0
  44. lvuse dir.gc $sc_id
  45. lvmulti first
  46. if $lv_file = ""
  47.    ezreq "How's about choosing\nsome files first ?" 'Oh yeah..' ""
  48.    stop
  49. endif
  50. while $lv_file > ""
  51.    counter sc.filecount inc 1
  52.    lvuse dir.search 3
  53.    lvadd $lv_file
  54.    lvuse dir.gc $sc_id
  55.    lvmulti next
  56. endwhile
  57. setwintitle dir.search 'Enter substring to search for:'
  58. guiopen dir.search
  59. setgad dir.search 2 ON
  60.  
  61.  
  62. xOnOpen
  63. while $lv_file > ""
  64.    lvuse dir.search 3
  65.    lvadd $lv_file
  66.    lvuse dir.gc $sc_id
  67.    lvmulti next
  68. endwhile
  69. setwintitle dir.search 'Enter substring to search for:'
  70. setgad dir.search 2 ON
  71.  
  72. xOnClose
  73. guiquit dir.search
  74.  
  75. xOnQuit
  76. delvar .search
  77. guiquit dir.Gauge
  78. run 'resident fsearch remove'
  79.  
  80. xOnFail
  81. update dir.search 2 '*** Error during search ***'
  82. guiwindow dir.search resume
  83.  
  84.  
  85. ; ----------------------- gui handler
  86.  
  87. xroutine makegui
  88. if $sc.mode = RES
  89.    setgad dir.search 3 hide
  90.    setgad dir.search 4 show
  91.    setgad dir.search 11 hide
  92. else
  93.    setgad dir.search 3  show
  94.    setgad dir.search 4  hide
  95.    setgad dir.search 11 show  ; reload
  96. endif
  97. redraw dir.search
  98.  
  99. ;========================= Gadgets
  100.  
  101. xCycler  5 20 120 13 '' sc_ci
  102. cstr "Same Case"  ''  
  103. cstr "Ignore Case"  I
  104.  
  105. xCycler  125 20 120 13 '' sc_flg
  106. cstr 'Verbose'      ''
  107. cstr 'FLAG & NUM'   'FLAG NUM'
  108. cstr 'FLAG files'   'FLAG'
  109. cstr 'Line NUMbers' 'NUM'  
  110.  
  111. xcycler 300 20 95 13 '' sc.mode         ; change listviews etc
  112. gadid 6
  113. cstr Files    FIL
  114. cstr Results  RES
  115. gosub dir.search makegui
  116.  
  117. xbutton 250 20 50 13 Rld
  118. gadid 11
  119. if $$lv.id > ''
  120.    sc_id = $$lv.id
  121. else
  122.    sc_id = 1
  123. endif
  124. sc_dir = $$LV.DIR
  125. LVUSE dir.search 3
  126. lvchange ''
  127. gosub dir.search startup
  128.  
  129.  
  130. ;-------------------------------- the listviews
  131.  
  132. xlistview 5 35 390 114 "" sc_file "" 10 TXT      ; files list
  133. GADID 3
  134. cutvar sc_file cut word 1 sc_name
  135. ifexists file $sc_name
  136.    lv_file = $sc_name
  137.    guiopen dir.g2
  138. endif
  139.  
  140.  
  141. xlistview 5 35 390 114 "" sc_file "" 10 TXT      ; results
  142. GADID 4
  143. cutvar sc_file cut word 1 sc_name
  144. ifexists file $sc_name
  145.    cutvar sc_file cut word 1 sc_line
  146.    if $sc_line < 1
  147.       delvar sc_line
  148.    endif
  149.    lv_file = $sc_name
  150.    guiopen dir.g2
  151. endif
  152.  
  153. ; ------------------------ TEXT-IN + LAUNCH SEARCH
  154.  
  155. xTextIn  5 2 390 16 "" sc_string "" 130
  156. gadid 2
  157. delete ram:t/search
  158. lvuse dir.search 3
  159. lvgo #0
  160. sc_file = $$lv.rec
  161. guiopen dir.Gauge
  162. guiwindow dir.search wait
  163. sc.count = 0
  164. while $sc.count < $$lv.total
  165.    sc.percent == $sc.count * 100
  166.    sc.percent == $sc.percent / $sc.filecount
  167.    update dir.Gauge 1 $sc.percent
  168.    lvgo #$sc.count
  169.    sc_file = $$lv.rec
  170.    action cli $sc_file 'fsearch >>ram:t/search $$file \"$sc_string\" $sc_ci $sc_flg'
  171.    counter sc.count inc 1
  172. endwhile
  173. lvuse dir.search 4
  174. lvchange ram:t/search
  175. guiwindow dir.search resume
  176. guiclose dir.Gauge
  177. setwintitle dir.search 'Search finished - Click on filename wanted'
  178. if $sc.mode = FIL
  179.    sc.mode = RES
  180.    update dir.search 6 1
  181.    gosub dir.search makegui
  182. endif
  183.  
  184.  
  185. ;=====================
  186.  
  187. newfile dir.Gauge
  188.  
  189. winbig -1 -1 400 20 ''
  190. wintype 00001000
  191.  
  192. Gauge 0 0 0 0  out icondrop 3 0 0
  193. gadid 1
  194.  
  195.  
  196.